package com.lcy.demowebsocket.jms;

import com.lcy.demowebsocket.websocket.WebsocketEndPoint;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.annotation.JmsListener;
import org.springframework.stereotype.Component;

import java.io.IOException;

/**
 * 订阅消息
 */
@Component
public class Consumer {
    @Autowired
    private WebsocketEndPoint websocketEndPoint;

    /**
     * 监听 topic
     * @param text
     * @throws IOException
     */
    @JmsListener(destination = "message")
    public void receiveQueue(String text) throws IOException {
        websocketEndPoint.sendMessage(text);
    }
}
